capt log close _all
log using   "${logs}Figure1" , replace text
*------------

// Time to run: around 30 seconds

*==================================================================
// Figure 1: BEV ownership share by household type, 2008-2017
*==================================================================

use    "${dataout}MainDataset" , clear

keep if year>=2008 & year<=2017
keep BEV_fam_yes year couple

collapse (mean) BEV_fam_yes , by(year couple)

twoway   ///
(connected BEV_fam_yes year if couple==1 , color(navy)  lcolor(navy) lpattern(solid) msym(O)) ///
(connected BEV_fam_yes year if couple==0 , color(gs6)   lcolor(gs6)  lpattern(dash)  msym(S)) ///
, legend(on order(1 "Couple" 2 "Single-adult" ) ring(0) pos(11))  ///
xlab(2008(1)2017)  xtitle("Year") ///
ylab(0(0.02)0.10) ytitle("BEV (yes = 1)") ///
graphregion(color(white)) scale(1.2)

graph export     "${figures}Figure1.png" , replace
graph export     "${figures}Figure1.pdf" , replace
graph save       "${figures}Figure1.gph" , replace

*------------
log close





